package com.qf.oa_system.controller;

import com.qf.oa_system.entity.Leaves;
import com.qf.oa_system.entity.Principal;
import com.qf.oa_system.entity.User;
import com.qf.oa_system.service.LeavesService;
import com.qf.oa_system.service.PrincipalService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.io.Serializable;
import java.util.List;

/**
 * У???(Principal)表控制层
 *
 * @author makejava
 * @since 2020-06-03 20:26:25
 */
@Controller
@RequestMapping("principal")
public class PrincipalController {
    /**
     * 服务对象
     */
    @Resource
    private PrincipalService principalService;
    @Resource
    private LeavesService leavesService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Principal selectOne(Integer id) {
        return this.principalService.queryById(id);
    }

    /**
     * 修改密码
     * @param userPassword
     * @param
     */
    @PostMapping("updatePWD")
    public void updatePWD(String userPassword, HttpSession session){
        System.out.println();
//        principalService.update(Principal)
    }

    /**
     *
     * 跳转请假审批页面
     * @param modelMap
     * @return
     */
    @GetMapping("/qingjia")
    public String getLeavesList(ModelMap modelMap){
        List<Leaves> stuLeaves = leavesService.getLeaves();
        for (Leaves leaves : stuLeaves){
            System.out.println(leaves);
        }
        modelMap.put("stuLeaves", stuLeaves);
        return "vacate";
    }

    /**
     * 审批
     * @return
     */
    @GetMapping("/agree")
    public String getleavesList(String lid){
        int leaveId = Integer.parseInt(lid);

        leavesService.agree(leaveId);

        return "redirect:/principal/qingjia";
    }

    /**
     * 查询学生成绩
     * 跳转成绩查看页面
     * @return
     */
    @PostMapping("chengji")
    public String chengji(){


        return "";
    }


}